Watch Introductory Video
Download
Alternatively you can include Stetho from Maven Central via Gradle or Maven.
// Gradle dependency on Stetho
dependencies {
compile 'com.facebook.stetho:stetho:1.5.1'
}
<dependency>
<groupid>com.facebook.stetho</groupid>
<artifactid>stetho</artifactid>
<version>1.5.1</version>
</dependency>
Only the main stetho
dependency is strictly required, however you may also wish to use one of the network helpers:
dependencies {
compile 'com.facebook.stetho:stetho-okhttp3:1.5.1'
}
or:
dependencies {
compile 'com.facebook.stetho:stetho-okhttp:1.5.1'
}
or:
dependencies {
compile 'com.facebook.stetho:stetho-urlconnection:1.5.1'
}
Features
![Chrome DevTools Chrome DevTools](static/images/inspector-discovery.png)
Chrome DevTools
The integration with the Chrome DevTools frontend is implemented using a client/server protocol which the Stetho software provides for your application. Once your application is integrated, simply navigate to chrome://inspect
and click “Inspect” to get started!
![Network Inspection Network Inspection](static/images/inspector-network.png)
Network Inspection
Network inspection is possible with the full spectrum of Chrome Developer Tools features, including image preview, JSON response helpers, and even exporting traces to the HAR format.
![Database Inspection Database Inspection](static/images/inspector-sqlite.png)
Database Inspection
SQLite databases can be visualized and interactively explored with full read/write capabilities.
![View Hierarchy View Hierarchy](static/images/inspector-elements.png)
View Hierarchy
View hierarchy support for ICS (API 15) and up! Lots of goodies such as
![dumpapp dumpapp](static/images/dumpapp-prefs.png)
dumpapp
Dumpapp extends beyond the DevTools UI features shown above to provide a much more extensible, command-line interface to application components. A default set of plugins is provided, but the real power of dumpapp is the ability to easily create your own!
![Javascript Console Javascript Console](static/images/inspector-js.png)
Javascript Console
Javascript Console allows for execution of javascript code that can interact with the application or even the Android SDK.
Integrations
Setup
Integrating with Stetho is intended to be seamless and straightforward for most existing Android applications. There is a simple initialization step which occurs in your Application
class:
public class MyApplication extends Application {
public void onCreate() {
super.onCreate();
Stetho.initializeWithDefaults(this);
}
}
This brings up most of the default configuration but does not enable some additional hooks (most notably, network inspection). See below for specific details on individual subsystems.
Enable Network Inspection
If you are using the popular OkHttp library at the 2.2.x+ or 3.x release, you can use the Interceptors system to automatically hook into your existing stack. This is currently the simplest and most straightforward way to enable network inspection.
For OkHttp 2.x
OkHttpClient client = new OkHttpClient();
client.networkInterceptors().add(new StethoInterceptor());
For OkHttp 3.x
new OkHttpClient.Builder()
.addNetworkInterceptor(new StethoInterceptor())
.build();
As interceptors can modify the request and response, add the Stetho interceptor after all others to get an accurate view of the network traffic.
If you are using HttpURLConnection
, you can use StethoURLConnectionManager
to assist with integration though you should be aware that there are some caveats with this approach. In particular, you must explicitly add Accept-Encoding: gzip
to the request headers and manually handle compressed responses in order for Stetho to report compressed payload sizes.
See the stetho-sample project for more details.
Custom dumpapp Plugins
Custom plugins are the preferred means of extending the dumpapp system and can be added easily during configuration. Simply replace your configuration step as such:
Stetho.initialize(Stetho.newInitializerBuilder(context)
.enableDumpapp(new DumperPluginsProvider() {
@Override
public Iterable<DumperPlugin> get() {
return new Stetho.DefaultDumperPluginsBuilder(context)
.provide(new MyDumperPlugin())
.finish();
}
})
.enableWebKitInspector(Stetho.defaultInspectorModulesProvider(context))
.build());
See the stetho-sample project for more details.
Contributions
Use GitHub issues for requests. We actively welcome pull requests; learn how to contribute.
###Changelog Changes are tracked as GitHub releases.
###License
Stetho is BSD-licensed. We also provide an additional patent grant.